import { legacy_createStore as createStore } from 'redux'
import cloneDeep from 'lodash/cloneDeep'
// redux调试工具
import { composeWithDevTools } from '@redux-devtools/extension'

// 初始化state数据
const initState = {
  count: 100
}

const reducers = (state = initState, action) => {
  // 深拷贝
  let newState = cloneDeep(state)

  if (action.type === 'ADD') newState.count = newState.count + action.payload
  return newState
}

const store = createStore(reducers, composeWithDevTools())

export default store
